package com.example.a22310.myapplication.Activity;
//训练报名

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.example.a22310.myapplication.R;
import com.example.a22310.myapplication.ViewModel.Activity.TrainApplyViewModel;
import com.example.a22310.myapplication.databinding.ActivityAcapplyBinding;
import com.squareup.picasso.Picasso;

public class TrainApply  extends AppCompatActivity {
    private ActivityAcapplyBinding binding;
    private String FILENAME = "yuejian'data";
    private int userid;
    Bundle bundle;
    private String name,price;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.setContentView(this, R.layout.activity_acapply);
        Intent intent = getIntent();
        bundle = intent.getExtras();
        int id = bundle.getInt("activityid");
        initialize();
        new TrainApplyViewModel(this,binding,userid,id);


    }

    private void initialize(){
        binding.activityName.setText(bundle.getString("name"));
        name = bundle.getString("name");
        price = bundle.getString("price");
        binding.applyPrice.setText(bundle.getString("price"));
        userid = getUserid();
        binding.sum.setText(price);
        Picasso.with(TrainApply.this).load(bundle.getString("str")).into(binding.pic);
        binding.must.setText(bundle.getString("intro"));
    }
    private int  getUserid(){
        int newsNumber;
        SharedPreferences sharedPreferences = getSharedPreferences(FILENAME, Context.MODE_PRIVATE);
        newsNumber = sharedPreferences.getInt("userId",0);
        return newsNumber;
    }
}
